package util

import (
	"flag"
	"fmt"
	"os"
	"path/filepath"
	"strings"
)

func usage() {
	fmt.Printf("\nUsage: %s [-s adhoc] [-h]\n\nOptions:\nStarRocks Buckets分桶修复工具\n", filepath.Base(os.Args[0]))
	flag.PrintDefaults()
	fmt.Println()
}

func init() {
	var help bool
	flag.StringVar(&Action, "m", "create,insert,alter,drop", "execution method: create,insert,alter,drop")
	flag.StringVar(&Table, "t", "", "schema.tablename")
	flag.Int64Var(&Buckets, "b", 0, "buckets")
	flag.StringVar(&BackendId, "id", "", "根据backendId1,根据backendId2...展示节点内存储的分片信息")
	flag.StringVar(&SplitKey, "sk", "", "splitkey1,splitkey2..., 重建表时可以重新指定分桶键")
	flag.StringVar(&StarRocks, "s", "", "starrocks:adhoc|app|scct|cdp|api|dmp|emr(企业版),emrc(社区版)|qa")
	flag.BoolVar(&help, "h", false, "show help information")
	flag.BoolVar(&List, "l", false, "展示排序键信息")
	flag.BoolVar(&Auto, "a", false, "启用自动模式匹配表最佳分桶，完成覆盖")
	flag.BoolVar(&ClearPartition, "c", false, "重建表时可以指定是否过滤空分区")
	flag.Int64Var(&TabletSize, "n", 0, "按单个Tablet容量进行切割/MB")
	flag.IntVar(&Thread, "thread", 3, "当启用自动模式匹配表最佳分桶，-t填写多个表名时，可触发并行模式")

	flag.Parse()
	flag.Usage = usage

	if !strings.Contains(Table, ".") {
		flag.Usage()
		os.Exit(1)
	}
	if help || len(StarRocks) == 0 || len(Table) == 0 {
		flag.Usage()
		os.Exit(-1)
	}

}

func Parm() {
}
